﻿<%@ WebHandler Language="C#" Class="AutomationDetail" %>

using System;
using System.Web;
using System.Xml;

public class AutomationDetail : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        int appId = Convert.ToInt32(context.Request.Form["id"]);
        context.Response.ContentType = "text/html";
        string fileName = HttpContext.Current.Server.MapPath(Constant.XmlFileName);
        Automation automation = new DataLoader(fileName).GetAutomationById(appId);
        context.Response.Write(ToHtmlFormat(automation));
    }

    private string ToHtmlFormat(Automation automation)
    {
        return string.Format(@"<p><b>Region: {0} | Sector: {1}</b></p><hr/>{2}", automation.Region, automation.Sector, automation.Description);
    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}